package org.dairy.farms.model;

import org.dairy.farms.interceptor.hibernate.Auditable;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: gduggira
 * Date: Jun 9, 2011
 * Time: 9:26:31 AM
 */
@Table(name = "EXPENSE_TYPE")
@Entity
public class ExpenseType implements Auditable {

    public static final String PERSON_MONTHLY_PAY = "PERSON_MONTHLY_PAY";
    public static final String LIVESTOCK_PURCHASE_EXPENSE = "LIVESTOCK_PURCHASE_EXPENSE";
    public static final String LIVESTOCK_MISC_EXPENSE = "LIVESTOCK_MISC_EXPENSE";
    public static final String LIVESTOCK_FEED_EXPENSE = "LIVESTOCK_FEED_EXPENSE";
    public static final String LIVESTOCK_CHECKUP_EXPENSE = "LIVESTOCK_CHECKUP_EXPENSE";
    public static final String FARM_WORK_FORCE_EXPENSE = "FARM_WORK_FORCE_EXPENSE";
    public static final String FARM_MISC = "FARM_MISC";
    public static final String FARM_INFRA_EXPENSE = "FARM_INFRA_EXPENSE";
    public static final String FARM_FEED_CUL_EXPENSE = "FARM_FEED_CUL_EXPENSE";

    public static final String EXPENSE_TYPE_OF_PERSON = "PERSON";
    public static final String EXPENSE_TYPE_OF_FARM = "FARM";
    public static final String EXPENSE_TYPE_OF_LIVESTOCK = "LIVESTOCK";
    
    @javax.persistence.Column(name = "ID")
    @Id
    @GeneratedValue
    private Long id;

    @javax.persistence.Column(name = "NAME")
    private String name;

    @javax.persistence.Column(name = "DESCRIPTION")
    private String description;

    @Column(name = "EXPENSE_TYPE_OF")
    private String expenseTypeOf;

    @OneToMany(mappedBy = "expenseType",targetEntity = Expense.class,cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    private Set<Expense> expenses = new HashSet<Expense>();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Expense> getExpenses() {
        return expenses;
    }

    public void setExpenses(Set<Expense> expenses) {
        this.expenses = expenses;
    }

    public String getExpenseTypeOf() {
        return expenseTypeOf;
    }

    public void setExpenseTypeOf(String expenseTypeOf) {
        this.expenseTypeOf = expenseTypeOf;
    }

    @Embedded
    private AuditInfo auditInfo = new AuditInfo();
    public AuditInfo getAuditInfo() {
        return auditInfo;
    }

    public void setAuditInfo(AuditInfo auditInfo) {
        this.auditInfo = auditInfo;
    }
}
